import React from "react";
import PropTypes from 'prop-types';
import { saveFormData, saveImg, clearData } from '../../store/home/action';
import { connect } from 'react-redux'
import Header from "../../components/Header";
import {NavLink} from "react-router-dom";
// import Http from '../http/config'
// import Api from '../http/api'
import HomeComponent from '../../components/Home'
class userList extends React.Component{
    static propTypes = {
        formData: PropTypes.object.isRequired,
        saveFormData: PropTypes.func.isRequired,
        saveImg: PropTypes.func.isRequired,
        clearData: PropTypes.func.isRequired,
    }
    componentWillMount(){
        // let obj = {
        //     noHttpLoading: false,
        //     params: {
        //         phone:"",
        //         pwd:"",
        //     }
        // };
        // Http.post(Api.login.login, obj).then((res) => {
        //     console.log(res)
        // }).catch((err)=>{
        //     console.log(err)
        // })
        console.log(this.props)
        this.setState({
            myUserName:"12345464",
            color:"#568989"
        })

    }
    onChange = (e) => {
        this.props.saveFormData(e.target.value,"name");
    }
    onClick = (e) => {
        this.props.saveFormData(this.props.formData.orderSum+1,"orderSum");
    }
    handleForm(){
        console.log(1)
    }
    render(){
        return (
            <div>
                <Header></Header>
                <div>state:{this.state.myUserName}</div>
                <div>dasdasdasdas</div>
                <p>user: {this.props.formData.name}, orderSum: {this.props.formData.orderSum}</p>
                user:
                <input type="text" className="input" name="name" onChange={this.onChange}/>
                &nbsp;

                <button className="btn" onClick={this.onClick}>年龄增长</button>
                <div>
                      <HomeComponent clickForm={this.handleForm} />
                    12313
                </div>

                <div style={{color: this.state.color}}>asdas</div>
                <NavLink to="/user">user</NavLink>
            </div>

        );
    }
}

connect(store => ({
    formData:store.homeData,
    userData:store.userData
}),{saveFormData, saveImg, clearData})(userList);


